import { useMemo } from 'react'
import { HashRouter, useHistory, useLocation } from 'react-router-dom'
// 全局通用的路由实例
// export const router = new HashRouter()
// // 将对象转化为查询字符串
// export const formatObjectToQs = (obj) => Object.keys(obj).reduce((prev, key) => (`${prev}${key}=${obj[key]}&`), '?')
// // 将查询字符串转化为对象
// export const formatQsToObject = (str) => {
//   if (str.startsWith('?')) str = str.slice(1)
//   return str.split('&').reduce((prev, curr) => {
//     if (!curr) return prev
//     const [key, value] = curr.split('=')
//     prev[key] = value
//     return prev
//   }, {})
// }
// // 回到首页
// export const handleBackToMain = () => {
//   router.history.push('/')
// }
// // 回到首页hook
// export const useBackMain = () => {
//   const history = useHistory()
//   return () => history.push('/')
// }
// export const useQuery = () => {
//   const { search } = useLocation()
//   const query = useMemo(() => formatQsToObject(search), [search])
//   return query
// }
